//
//  MZmoreViewController.m
//  民族文化宫
//
//  Created by kobehjk on 14-8-14.
//  Copyright (c) 2014年 WANG CUNRUI. All rights reserved.
//

#import "MZmore2ViewController.h"

@interface MZmore2ViewController ()
@property (strong, nonatomic) UIImageView *imageView;
@property (strong, nonatomic) UILabel *label;
@end

@implementation MZmore2ViewController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    self.edgesForExtendedLayout = UIRectEdgeNone;
    self.view.backgroundColor = [UIColor whiteColor];
    _imageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"m4.png"]];
    _imageView.frame = CGRectMake(0, 0, 320,200);
    [self.view addSubview:_imageView];
    _label = [[UILabel alloc] initWithFrame:CGRectMake(0, 250, 0, 0)];
    [_label setNumberOfLines:0];
    _label.lineBreakMode = NSLineBreakByWordWrapping;
    _label.font = [UIFont boldSystemFontOfSize:15];
    // 测试字串
    NSString *s = [NSString stringWithFormat:@""];
    _label.text = s;
    //设置一个行高上限
    CGSize size = CGSizeMake(320,400);
    //计算实际frame大小，并将label的frame变成实际大小
    NSDictionary *attribute = @{NSFontAttributeName: _label.font};
    CGSize labelsize = [_label.text boundingRectWithSize:size options: NSStringDrawingTruncatesLastVisibleLine |NSStringDrawingUsesLineFragmentOrigin | NSStringDrawingUsesFontLeading attributes:attribute context:nil].size;
    _label.frame = CGRectMake(0,220, labelsize.width, labelsize.height);
    [self.view addSubview:_label];

}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
